// video.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    navTab: ["热门推荐", "原创精选", "精彩片段", "教学视频"],
    currentNavtab: 0,
    videoList: [
    ]
  },

  switchTab: function (e) {
    this.setData({
      currentNavtab: e.currentTarget.dataset.idx
    });
    this.refreshVideoList();
  },

  refreshVideoList: function () {
    var newList = new Array();
    if (this.data.currentNavtab == 0) {
      newList[0] = this.createVideo(1, "360flip", "http://otkt4n8n4.bkt.clouddn.com/360%20flip.mp4");
      newList[1] = this.createVideo(2, "pop shove it", "http://otkt4n8n4.bkt.clouddn.com/pop%20shove%20it.mp4");
      newList[2] = this.createVideo(3, "BS ollie 180", "http://otkt4n8n4.bkt.clouddn.com/BS%20180.mp4");
      newList[3] = this.createVideo(4, "BS ollie 180 and fakie kickflip", "http://otkt4n8n4.bkt.clouddn.com/video/BS%20ollie%20fakie%20kickflip.mp4");
      newList[4] = this.createVideo(5, "FS ollie 180", "http://otkt4n8n4.bkt.clouddn.com/video/FS%20ollie%203li.mp4");
      newList[5] = this.createVideo(6, "BS heelflip", "http://otkt4n8n4.bkt.clouddn.com/video/BS%20heelflip.mp4");
      newList[6] = this.createVideo(7, "BS kickflip", "http://otkt4n8n4.bkt.clouddn.com/video/BS%20kickflip%203.mp4");
      console.log("1tab"); 
      this.setData({
        videoList: newList
      });

    } else if (this.data.currentNavtab == 1) {
      newList[0] = this.createVideo(3, "BS ollie 180", "http://otkt4n8n4.bkt.clouddn.com/BS%20180.mp4");
      newList[1] = this.createVideo(4, "BS ollie 180 and fakie kickflip", "http://otkt4n8n4.bkt.clouddn.com/video/BS%20ollie%20fakie%20kickflip.mp4");
      newList[2] = this.createVideo(5, "FS ollie 180", "http://otkt4n8n4.bkt.clouddn.com/video/FS%20ollie%203li.mp4");
      console.log("2tab"); 
      this.setData({
        videoList: newList
      });

    } else if (this.data.currentNavtab == 2) {
      newList[0] = this.createVideo(4, "BS ollie 180 and fakie kickflip", "http://otkt4n8n4.bkt.clouddn.com/video/BS%20ollie%20fakie%20kickflip.mp4");
      newList[1] = this.createVideo(5, "FS ollie 180", "http://otkt4n8n4.bkt.clouddn.com/video/FS%20ollie%203li.mp4");
      console.log("3tab"); 
      this.setData({
        videoList: newList
      });

    } else if (this.data.currentNavtab == 3) {
      newList[0] = this.createVideo(6, "BS heelflip", "http://otkt4n8n4.bkt.clouddn.com/video/BS%20heelflip.mp4");
      newList[1] = this.createVideo(7, "BS kickflip", "http://otkt4n8n4.bkt.clouddn.com/video/BS%20kickflip%203.mp4");
      console.log("4tab");
      this.setData({
        videoList: newList
      });
    }


  },

  createVideo: function (id, name, url) {
    var video = new Object();
    video.id = id;
    video.name = name;
    video.url = url;
    return video;
  },


  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.refreshVideoList();
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})